# API网关配置

import os
from typing import List
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    """
    API网关配置类
    """
    # 项目基本信息
    PROJECT_NAME: str = "音视频转换API网关"
    PROJECT_DESCRIPTION: str = "统一管理音频转文字和视频转语音服务的API网关"
    VERSION: str = "0.1.0"
    API_PREFIX: str = "/api/v1"
    
    # CORS配置
    CORS_ORIGINS: str = "http://localhost:3000"
    
    @property
    def cors_origins_list(self) -> List[str]:
        """将CORS_ORIGINS字符串转换为列表"""
        if isinstance(self.CORS_ORIGINS, str):
            return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
        return self.CORS_ORIGINS
    
    # 服务配置
    AUDIO_TO_TEXT_SERVICE_URL: str = os.getenv("AUDIO_TO_TEXT_SERVICE_URL", "http://localhost:8000")
    VIDEO_TO_SPEECH_SERVICE_URL: str = os.getenv("VIDEO_TO_SPEECH_SERVICE_URL", "http://localhost:8001")
    
    # 安全配置
    API_KEY_HEADER: str = "X-API-Key"
    API_KEY: str = os.getenv("API_KEY", "test-api-key")
    
    # 服务健康检查配置
    HEALTH_CHECK_INTERVAL: int = 60  # 秒
    
    model_config = {
        "case_sensitive": True,
        "env_file": ".env"
    }

# 创建全局设置实例
settings = Settings()